package com.farah.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.farah.lease.model.entity.SystemPost;
import com.farah.lease.model.entity.SystemUser;
import com.farah.lease.web.admin.mapper.SystemPostMapper;
import com.farah.lease.web.admin.mapper.SystemUserMapper;
import com.farah.lease.web.admin.service.SystemUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.farah.lease.web.admin.vo.system.user.SystemUserItemVo;
import com.farah.lease.web.admin.vo.system.user.SystemUserQueryVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author 不爱跑步的法拉韶
 * @Date 2024-06-21__12:08
 * @description 针对表【system_user(员工信息表)】的数据库操作Service实现
 */
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser>
        implements SystemUserService {

    @Autowired
    private SystemUserMapper systemUserMapper;

    @Autowired
    private SystemPostMapper systemPostMapper;

    @Override
    public IPage<SystemUserItemVo> pageSystemUserByQuery(IPage<SystemUser> page, SystemUserQueryVo queryVo) {
        return systemUserMapper.pageSystemUserByQuery(page,queryVo);
    }



    @Override
    public SystemUserItemVo getSystemUserById(Long id) {
        SystemUserItemVo systemUserItemVo=new SystemUserItemVo();
        SystemUser user = systemUserMapper.selectById(id);
        SystemPost systemPost = systemPostMapper.selectById(user.getPostId());
        systemUserItemVo.setId(user.getId());
        systemUserItemVo.setName(user.getName());
        systemUserItemVo.setPostName(systemPost.getName());
        systemUserItemVo.setPhone(user.getPhone());
        systemUserItemVo.setStatus(user.getStatus());
        systemUserItemVo.setUsername(user.getUsername());
        systemUserItemVo.setAvatarUrl(user.getAvatarUrl());
        systemUserItemVo.setAdditionalInfo(user.getAdditionalInfo());
        systemUserItemVo.setType(user.getType());
        return systemUserItemVo;
    }
}




